package com.test.service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.junit.internal.runners.statements.ExpectException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.test.bean.Student;
import com.test.dao.BaseDao;

@Service(value =  "studentServiceImpl")
public class StudentServiceImpl implements StudentService {
	public StudentServiceImpl(){
		System.out.println("fee");
	}
	@Autowired
	private BaseDao baseDao;
	
	@Override
	public List<Map<String, Object>> getAllStudent() {
		List<Map<String, Object>> list = baseDao.selectList("getAllStudent");
		return list;
	}
	@Override
	public List<Student> getAllreturnStudent() {
		List<Student> list = baseDao.selectList("getAllreturnStudent");
		return list;
	}
	@Override
	public void addStudent(Student student) {
		int i = baseDao.insert("addStudent", student);
		System.out.println("add flag i: "+i);
	}

	@Override
	public void updateStudent(Student student) {
		int i = baseDao.insert("updateStudent", student);
		System.out.println("updateStudent flag i: "+i);

	}
	@Override
	public void addupdateStudent() {
		Student student = new Student();
		student.setStudent_id("16");
		student.setStudentName("addupdateStudent");
		student.setBirthday(new Date());
		student.setTeacher_id("22");
		int i = baseDao.insert("addStudent", student);
		student.setStudentName("updateStudent22");
		Exception e = new Exception(" stop ");
		e.printStackTrace();
		int j = baseDao.insert("updateStudent", student);
	}
	@Override
	public void deleteStudent(String id) {
		// TODO Auto-generated method stub

	}

	@Override
	public Student getOneStudent(String id) {
		List<Student> list = baseDao.selectList("getoneStudent",id);
		if(list!=null&&list.size()>0){
			return list.get(0);
		}
		return null;
	}

	@Override
	public Student getOneStudentByResultMap(String id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Map<String, Object>> getAllStudentByResultMap() {
		//List<Map<String, Object>> list = baseDao.selectList("com.test.bean.Student.getAllStudentByResultMap");
		return null;
	}

	@Override
	public List<Map<String, Object>> getAllStudentAndTeacherByResultMap() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Student getOneStudentAndTeacherByResultMap() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Student getOneStudentAndTeacherBySelect(String id) {
		// TODO Auto-generated method stub
		return null;
	}
	

}
